package com.huiquan.icd.dao;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.huiquan.framework.base.EnhancedBaseDao;
import com.huiquan.icd.domain.IcdDiseaseSectionBlackWhite;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class IcdDiseaseSectionBlackWhiteDao extends EnhancedBaseDao<IcdDiseaseSectionBlackWhite> {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "ICD_DISEASE_SECTION_BLACK_WHITE.";

	public IcdDiseaseSectionBlackWhiteDao() {
		super(space);
	}

	/**
	 * 获取数据总数
	 * 
	 * @return
	 */
	public int checkRepeat(String array, String partPattern, String descriptionId, String id) {
		Map<String, Object> param = new HashMap<>();
		param.put("array", array);
		param.put("partPattern", partPattern);
		param.put("description_id", descriptionId);
		param.put("id", id);
		Integer size = (Integer) this.object(space + "CHECK_REPEAT", param, sqlMapClient);
		return size == null ? 0 : size;
	}

	public void updateFlag(String id, String flag, Long userId) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		param.put("flag", flag);
		param.put("uid", userId);
		update(space + "UPDATE_FLAG", param, sqlMapClient);
	}

	public void updateSubmit(String id, Long userId) {
		Map<String, Object> param = new HashMap<>();
		param.put("ids", id);
		param.put("uid", userId);
		update(space + "UPDATE_CHECK_FLAG", param, sqlMapClient);
	}

}
